package com.test.exam.dao;

import java.util.HashMap;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.test.exam.commons.PageHelper;
import com.test.exam.domain.Ban;

@Repository
public class BanDao {
	private final String BAN_NS = "com.test.exam.mapper.BanMapper";
	@Autowired 
	private SqlSessionTemplate sqlSessionTemplate;
	
	
	// 전체 반 row수
	public int getBanCount(){
		return sqlSessionTemplate.selectOne(
				BAN_NS+".getBanCount");
	}
	
	// 페이지 반 목록
	public List<HashMap> getBansByCurrentPage(PageHelper pageHelper){
		return  sqlSessionTemplate.selectList(
				BAN_NS+".getBansByCurrentPage",pageHelper);
	}
	// 전체 반 목록
	public List<HashMap> getAllBans(){
		return sqlSessionTemplate.selectList(
				BAN_NS+".getAllBans");
	}
	
	// 반 입력
	public int addBan(Ban ban){
		return sqlSessionTemplate.insert(
				BAN_NS+".addBan", ban);
	}
}
